#pragma once


#include "Widgets/Widget.h"
#include "PercentPositionerWidget.m.h"

//positioner widget with percent position
//only worked on first child,other children will be ignored.
//child must provide a fixed width and height to calculate position
//Child's X=- Child's Width*XPercent
//Child's Y=- Child's Height*YPercent
RCLASS()
class WHENGINE_API RPercentPositionerWidget : public RWidget
{
    ROBJECT

public:
    //percent of parent's width ,(0,1)  
    TWidgetAttribute<float> XPercent = 0.f;
    TWidgetAttribute<float> YPercent = 0.f;


    virtual void CalculatePresentPositionAndSize() override;
    virtual void CalculateChildrenPresentPositionAndSize() override;
    virtual float CalculateContentWidth() override;
    virtual float CalculateContentHeight() override;

    void ArrangeChildren();

    TDelegate<void> OnChildrenArranged;    

protected:
    bool bChildrenArranged=false;
    SVec2 ContentSize;

};